module CategoriesHelper
  def categories_index_fields(options)
    %w[name parent actions]
  end
  
  def categories_format_field(obj, field, options)
    case field
    when "name"
      obj.full_name
    when "parent"
      obj.parent.name rescue "[none]"
    when "actions"
      action_links(obj, :exclude => :show)
    else
      obj.send(field)
    end
  end
  
  def categories_index_links(objs, options)
    [link_to("Create new category", new_category_path)]
  end
end
